﻿using System.Linq;
using Abp.Authorization;
using Abp.Localization;
using LeadThing.AbpZeroTemplate.Authorization;



namespace LeadThing.AbpZeroTemplate.DisputeInformations.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="DisputeInformationAppPermissions"/> for all permission names.
    /// </summary>
    public class DisputeInformationAppAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            //在这里配置了DisputeInformation 的权限。

            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));

            var entityNameModel = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_DisputeData)
              ?? pages.CreateChildPermission(AppPermissions.Pages_DisputeData, L("Pages_DisputeData"));


            //矛盾纠纷受理
            var disputeInformation = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformation, L("DisputeInformation"));
            disputeInformation.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformation_CreateDisputeInformation, L("CreateDisputeInformation"));
            disputeInformation.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformation_EditDisputeInformation, L("EditDisputeInformation"));
            disputeInformation.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformation_DeleteDisputeInformation, L("DeleteDisputeInformation"));

            //矛盾纠纷处理
            var handle = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationHandle, L("DisputeInformationHandle"));
            handle.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationHandle_Shunt, L("Shunt"));
            handle.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationHandle_Mediation, L("Mediation"));
            handle.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationHandle_Detail, L("Detail"));
            handle.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationHandle_ViewWorkFlowProcess, L("ViewWorkFlowProcess"));

            //调查调处
            var diaoChaDiaoChu = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.DiaoChaDiaoChu, L("DiaoChaDiaoChu"));
            diaoChaDiaoChu.CreateChildPermission(DisputeInformationAppPermissions.DiaoChaDiaoChu_Suggestion, L("Suggestion"));
            diaoChaDiaoChu.CreateChildPermission(DisputeInformationAppPermissions.DiaoChaDiaoChu_Success, L("Success"));
            diaoChaDiaoChu.CreateChildPermission(DisputeInformationAppPermissions.DiaoChaDiaoChu_Fail, L("Failed"));
            diaoChaDiaoChu.CreateChildPermission(DisputeInformationAppPermissions.DiaoChaDiaoChu_Detail, L("Detail"));
            diaoChaDiaoChu.CreateChildPermission(DisputeInformationAppPermissions.DiaoChaDiaoChu_ViewWorkFlowProcess, L("ViewWorkFlowProcess"));

            //上传协议书
            var agreement = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.Agreement, L("UploadAgreement"));
            agreement.CreateChildPermission(DisputeInformationAppPermissions.Agreement_UploadAgreement, L("UploadAgreement"));
            agreement.CreateChildPermission(DisputeInformationAppPermissions.Agreement_Refuse, L("Refuse"));
            agreement.CreateChildPermission(DisputeInformationAppPermissions.Agreement_Detail, L("Detail"));
            agreement.CreateChildPermission(DisputeInformationAppPermissions.Agreement_ViewWorkFlowProcess, L("ViewWorkFlowProcess"));

            //履行协议
            var performanceAgreement = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.PerformanceAgreement, L("PerformanceAgreement"));
            performanceAgreement.CreateChildPermission(DisputeInformationAppPermissions.PerformanceAgreement_Perform, L("Perform"));
            performanceAgreement.CreateChildPermission(DisputeInformationAppPermissions.PerformanceAgreement_Unfulfilled, L("Unfulfilled"));
            performanceAgreement.CreateChildPermission(DisputeInformationAppPermissions.PerformanceAgreement_Detail, L("Detail"));
            performanceAgreement.CreateChildPermission(DisputeInformationAppPermissions.PerformanceAgreement_ViewWorkFlowProcess, L("ViewWorkFlowProcess"));

            //结案归档
            var jieAnGuiDang = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationJieAnGuiDang, L("JieAnGuiDang"));
            jieAnGuiDang.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationJieAnGuiDang_Confirm, L("ConfirmationArchiving"));
            jieAnGuiDang.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationJieAnGuiDang_Detail, L("Detail"));
            jieAnGuiDang.CreateChildPermission(DisputeInformationAppPermissions.DisputeInformationJieAnGuiDang_ViewWorkFlowProcess, L("ViewWorkFlowProcess"));

            //需转交其他渠道解决
            var otherChannels = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.OtherChannels, L("OtherChannels"));
            otherChannels.CreateChildPermission(DisputeInformationAppPermissions.OtherChannels_Detail, L("Detail"));
            otherChannels.CreateChildPermission(DisputeInformationAppPermissions.OtherChannels_ViewWorkFlowProcess, L("ViewWorkFlowProcess"));

            //跟踪督办
            var genZongDuBan = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.GenZongDuBan, L("GenZongDuBan"));

            //查看跟踪督办记录
            var dubanList = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.GenZongDuBan_DuBanList, L("DuBanList"));

            //分析研判
            var fenXiYanPan = entityNameModel.CreateChildPermission(DisputeInformationAppPermissions.FenXiYanPan, L("FenXiYanPan"));

        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, AbpZeroTemplateConsts.LocalizationSourceName);
        }
    }

}